import datetime
import uuid

from django.db import models

# Create your models here.

class Users(models.Model):
    useraccount = models.CharField(max_length=20,unique=True)
    username = models.CharField(max_length=30)
    useremail = models.CharField(max_length=50)
    userphone = models.CharField(max_length=25)
    userpass = models.CharField(max_length=255)
    userimg = models.CharField(max_length=255)
    imgwight = models.IntegerField(default=200)
    imgheight = models.IntegerField(default=200)

    def __str__(self):
        return self.username

    class Meta:
        db_table='users'
        verbose_name='用户'
        verbose_name_plural=verbose_name

class Cities(models.Model):
    name = models.CharField(max_length=255)
    score = models.IntegerField(default=0)
    class Meta:
        db_table = "cities"
        verbose_name = '城市'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.cityname

class Navs(models.Model):
    imgsrc = models.CharField(max_length=255)
    weight = models.IntegerField()
    height = models.IntegerField()
    city = models.ForeignKey(Cities,on_delete=True)
    class Meta:
        db_table = "navs"

class Stoges(models.Model):
    name = models.CharField(max_length=255)
    imgsrc = models.CharField(max_length=255)
    class Meta:
        db_table = "stoges"
        verbose_name = '商家'
        verbose_name_plural = verbose_name
    def __str__(self):
        return self.name
class Houses(models.Model):
    name = models.CharField(max_length=255)
    price = models.FloatField()
    imgsrc = models.CharField(max_length=255)
    lng=models.FloatField()
    lat=models.FloatField()
    placename=models.CharField(max_length=255)
    sindecripe = models.TextField(null=True)
    insiposition = models.TextField(null=True)
    traficposition = models.TextField(null=True)
    arround = models.TextField(null=True)
    lifeknows = models.TextField(null=True)
    stoge = models.ForeignKey(Stoges,on_delete=True)
    city = models.ForeignKey(Cities, on_delete=True)
    class Meta:
        db_table = "houses"

class Details(models.Model):
    name=models.CharField(max_length=255)
    class Meta:
        db_table = "details"

class HouseImg(models.Model):
    imgsrc = models.CharField(max_length=255)
    house = models.ForeignKey(Houses,on_delete=True)
    size = models.CharField(max_length=20)
    class Meta:
        db_table = "houseimgs"

class Settings(models.Model):
    name = models.CharField(max_length=255)
    house = models.ManyToManyField(to="Houses", name="houses")
    class Meta:
        db_table = "settings"

class Tags(models.Model):
    name = models.CharField(max_length=255)
    house = models.ManyToManyField(to="Houses", name="houses")
    class Meta:
        db_table = "tags"



class Comments(models.Model):
    msg = models.CharField(max_length=255)
    user = models.ForeignKey(Users,on_delete=True)
    house = models.ForeignKey(Houses,on_delete=True)
    reply = models.CharField(max_length=255)
    sendtime = models.DateTimeField(default=datetime.datetime.now())
    class Meta:
        db_table = "comments"

class Orders(models.Model):
    ordertime = models.DateField()
    startroom = models.DateField()
    ispay = models.BooleanField()
    regtime = models.DateTimeField(datetime.datetime.now())
    outtime = models.IntegerField(default=30)
    user = models.ForeignKey(Users, on_delete=True)
    house = models.ForeignKey(Houses, on_delete=True)
    class Meta:
        db_table = "orders"

